home *** CD-ROM | disk | FTP | other *** search
/ The Arsenal Files 8 / The Arsenal Files Collection #8 (Arsenal Computer) (1996).ISO / win_nt95 / cm95-10.zip / HARRIS.OZ < prev    next >
Text File  |  1996-10-29  |  7KB  |  216 lines

  1. ;Gets the latest Harris Poll. This poll on current issues is updated
  2. ;every Monday.
  3.  
  4. ;****************************************************************************
  5. ; ClockMan95 Automation Assistant support file
  6. ; (c) 1995 Graphical Dynamics, Inc. The "Common helper functions" are placed
  7. ; in the public domain; otherwise permission is granted to use/modify this
  8. ; script file as long as it's not for resale.
  9. ;
  10. ; Written by: Jennifer Palonus
  11. ;
  12. ; Date    Who    Major changes
  13. ;-------  ---    -------------------------------------------------------------
  14. ;16aug95  jlp    Created.
  15. ;****************************************************************************
  16.     define $ServiceName        ; used by GoService
  17.     define #ServiceHasHdr    ; used by GoService
  18.     define $MenuItem        ; used by ChooseMenuItem & FindMenuItem
  19.     define $SubjectLine        ; used by CaptureMsg
  20.     define $Prompt            ; used by WaitForPrompt
  21.     define #OK                ; used everywhere. Routines return %TRUE or /%FALSE
  22.     onerror HandleErrors
  23.     timeout 90
  24.  
  25.  
  26. ;****************************************************************************
  27. ; Main processing section.
  28. ;****************************************************************************
  29.     set $ServiceName    "CIS:SYN-27"
  30.     set #ServiceHasHdr  %FALSE
  31.     set $Prompt         ^M^J "!"
  32.     gosub GoService
  33.  
  34.     set $MenuItem       "Harris Poll"
  35.     gosub FindMenuItem
  36.     if #OK = %FALSE fail
  37.  
  38.      set $MenuItem       "1"
  39.     gosub ChooseMenuItem
  40.  
  41.     set $SubjectLine    "Latest Harris Poll"
  42.     gosub CaptureMsg
  43.     end
  44.  
  45.  
  46. ;****************************************************************************
  47. ; Common helper functions. (These are placed in the "public domain" by GDI.)
  48. ;****************************************************************************
  49. ; GoService
  50. ;
  51. ; Carries out a GO command & passes over the introductory text (if any).
  52. ; When this returns, you're ready to capture or parse the service's top menu.
  53. ;
  54. ; $ServiceName        The CIS service you want to GO to.
  55. ; #ServiceHasHdr    Does this service have an intro paragraph ending with a
  56. ;                    "MORE !" prompt?
  57. ;****************************************************************************
  58. GoService:
  59.     set #OK %TRUE
  60.     sendln "GO " $ServiceName
  61.  
  62.     if #ServiceHasHdr = %FALSE return
  63.     set $Prompt ^M^J "MORE !"         
  64.     gosub WaitForPrompt
  65.     send %CR
  66.     return
  67.  
  68.     
  69. ;****************************************************************************
  70. ; ChooseMenuItem
  71. ;
  72. ; Selects an article (by item #) from a menu. Upon return, you're ready to
  73. ; CaptureMsg it.
  74. ;
  75. ; $MenuItem            The menu selection #.
  76. ; $SubjectLine        The generated mail message's subject line if different
  77. ;                    than the default.
  78. ; $Prompt            The prompt that ends the article. Usu. ^M^J "!".
  79. ;****************************************************************************
  80. ChooseMenuItem:
  81.     set #OK %TRUE
  82.     set $Prompt ^M^J "!"
  83.     gosub WaitForPrompt
  84.  
  85.     sendln $MenuItem
  86.     wait ^M^J            ; Skip echo of menu item #
  87.     return
  88.  
  89.  
  90. ;****************************************************************************
  91. ; FindMenuItem
  92. ;
  93. ; Selects the first item in a menu that contains the string in $MenuItem.
  94. ; Assumes the menu is being sent & ready to parse.
  95. ;
  96. ; This is for services that keep adding articles to the front of the menu,
  97. ; and the article we're looking for always has the same title. There can end
  98. ; up being 0, 1, or more items with the same name, in unpredictable positions
  99. ; in the menu. The 1st one we find (lowest item #) is the most recent one.
  100. ; (ex.: AP's "Today in History", or "<day>'s Most Active Stocks", etc.)
  101. ;
  102. ; Using this routine also protects you when the provider moves items around
  103. ; within a menu. (It doesn't protect against the provider changing menu
  104. ; item names or moving items to other menus.)
  105. ;
  106. ; Upon return, #OK is %TRUE or %FALSE depending on whether any items were
  107. ; found that contained $MenuItem. If %TRUE then $MenuItem is also set to the
  108. ; full menu item description & caller is ready to capture or parse the
  109. ; selected article/submenu.
  110. ;
  111. ; If $MenuItem is found in the preface to the menu, then I guess we could get
  112. ; into trouble!
  113. ;
  114. ; $MenuItem            The menu selection name (or partial name).
  115. ; $SubjectLine        The generated mail message's subject line if different
  116. ;                    than the default.
  117. ; $Prompt            The prompt that ends the article. Usu. ^M^J "!".
  118. ;****************************************************************************
  119. FindMenuItem:
  120.     define $FMILine
  121.     define $FMIItem
  122.     define $FMINum
  123.     define #FMIToken
  124.     define #FMIFound
  125.  
  126.     set #OK %TRUE
  127.     FMILoop:
  128.         add 1 "!"
  129.         add 2 ^M^J                ; Examine each line in turn...
  130.         mwait #FMIToken
  131.         
  132.         if #FMIToken = 2 goto FMICheckWholeLine
  133.  
  134.         ; ...else this is either a "!" or "MORE !" prompt, or a
  135.         ; stray "!" or "MORE !" inside a whole line...
  136.         set $FMILine %COMDATA
  137.         trim $FMILine
  138.  
  139.         ; If multipart menu, tell CIS to send next part...
  140.         if $FMILine = "MORE !" send %CR
  141.         if $FMILine = "MORE !" goto FMILoop
  142.  
  143.         ; If end of full menu & item wasn't found...
  144.         if $FMILine = "!" set #OK %FALSE
  145.         if $FMILine = "!" return
  146.  
  147.         FMICheckWholeLine:
  148.         set $FMILine %LCOMDATA
  149.         
  150.         ; Split off what should be item description & check it...
  151.         midstr $FMILine 4 255 $FMIItem
  152.         posnc #FMIFound $MenuItem $FMIItem
  153.     if #FMIFound = 0 goto FMILoop
  154.     
  155.     ; If we get here, we've found $MenuItem in a line...
  156.     midstr $FMILine 1 2 $FMINum
  157.     trim $FMINum        ; We ASSUME first nonblank chars are a real menu item #!
  158.  
  159.     ; Now that we have our item, skip the rest of the menu...
  160.     set $Prompt ^M^J "!"
  161.     gosub WaitForPrompt
  162.     sendln $FMINum
  163.     wait ^M^J                    ; Skip echo of menu item #
  164.     set $MenuItem $FMIItem        ; Return full menu item description
  165.     return
  166.  
  167.  
  168. ;****************************************************************************
  169. ; CaptureMsg
  170. ;
  171. ; Assuming CIS is about to send us the text that we want to place into a mail
  172. ; message, this routine captures the text 'till we get a <CR> & ! prompt.
  173. ;
  174. ; $SubjectLine        The custom subject line if different than the default.
  175. ; $Prompt            The prompt that ends the article. Usu. ^M^J "!".
  176. ;****************************************************************************
  177. CaptureMsg:
  178.     set #OK %TRUE
  179.     capture on CISMAIL.MSG
  180.     if $SubjectLine =  "" WMH
  181.     if $SubjectLine <> "" WMH $SubjectLine
  182.  
  183.     gosub WaitForPrompt
  184.     capture off
  185.  
  186.     set $SubjectLine ""
  187.     return
  188.  
  189.  
  190. ;****************************************************************************
  191. ; WaitForPrompt
  192. ;
  193. ; Wait till the end of a menu or opening text. This routine handles menus
  194. ; split up into multiple chunks, each of which end in "MORE !" prompts.
  195. ; If you DO want to wait for "MORE !", then set $Prompt to it.
  196. ;
  197. ; $Prompt            The prompt you're waiting for. Usu. ^M^J "!".
  198. ;****************************************************************************
  199. WaitForPrompt:
  200.     define #WFPToken
  201.     set #OK %TRUE
  202.     
  203.     add 1 $Prompt
  204.     add 2 ^M^J "MORE !"
  205.     mwait #WFPToken
  206.     if #WFPToken = 2 send %CR
  207.     if #WFPToken = 2 goto WaitForPrompt
  208.  
  209.     return
  210.  
  211.  
  212. ;****************************************************************************
  213. HandleErrors:
  214.     fail
  215.  
  216.